const mongoose = require('mongoose')

function connectMongoDB(connectTo) {
    mongoose.connect(`${connectTo}`, {
        useUnifiedTopology: true,
        useNewUrlParser: true
    })
    let db = mongoose.connection; //数据库连接对象
    db.on('error', console.error.bind(console, 'connection error:'))
    db.once('open', function () {
        console.log('数据库连接成功');
    })
}
module.exports = {
    connectMongoDB
}